import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css全局样式
import i18n from '@/lang'
import App from './App'
import store from './store'
import router from './router'
// 注册指令
import * as directives from '@/directives'
import '@/icons' // icon
import '@/permission' // 权限  permission control
import Component from '@/components'
import * as filters from '@/filters'
import checkPermission from '@/mixins/checkPermission'
import LangSelect from './lang'
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
// 设置element为当前的语言
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})


// 注册自定义组件
Vue.use(Component)
// Vue.use({
//   install:function(){
//     console.log('注册全局组件');
//   }
// })
// 注册自定义指令
// 对象[属性名]=属性值
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})

// 用for in遍历
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// process是node环境运行的过程的一个变量，包含了关于node的相关信息
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// ElementUI全局注册
Vue.use(ElementUI, { locale })
// Vue.use(Component) // 注册自己的插件
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

// 关闭一些没必要的提示（控制台）
Vue.mixin(checkPermission)
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  LangSelect,
  render: h => h(App)
})


